package org.joseph.springcloud.controller;

import org.joseph.springcloud.pojo.User;
import org.joseph.springcloud.api.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class UserConsumerController {

    @Autowired
    private UserService userService;

    @RequestMapping("/user/{id}")
    @ResponseBody
    public User getUser(@PathVariable("id") long id){
        return userService.queryById(id);
    }

    @RequestMapping("/user2/{id}")
    @ResponseBody
    public User getUserHystrix(@PathVariable("id") long id){
        return userService.getUser(id);
    }

    @RequestMapping("/user2/getUserByname")
    @ResponseBody
    public String getUserByname(String name ,String gender){
        System.out.println(name+"is "+ gender);
        return "success";
    }

    @RequestMapping("/user2/getUserByuser")
    @ResponseBody
    public String getUserByuser(User user){
        System.out.println(user.getUsername()+"is "+ user.getId());
        return "success";
    }
}
